
#import "YSRegisterxmViewController.h"



















#import "YSDoViewManager.h"









#import "YSTextfield.h"



@interface YSRegisterxmViewController ()<UITextFieldDelegate>
@property (weak, nonatomic) IBOutlet UIView *userview;
@property (weak, nonatomic) IBOutlet UIView *mailview;
@property (weak, nonatomic) IBOutlet UIView *phoneview;
@property (weak, nonatomic) IBOutlet UIView *passview1;
@property (weak, nonatomic) IBOutlet UIView *passview2;
@property (weak, nonatomic) IBOutlet UIView *checkview;
@property (weak, nonatomic) IBOutlet UITextField *user_tx;
@property (weak, nonatomic) IBOutlet UITextField *mail_tx;
@property (weak, nonatomic) IBOutlet UITextField *phone_tx;
@property (weak, nonatomic) IBOutlet UITextField *pass_tx1;
@property (weak, nonatomic) IBOutlet UITextField *pass_tx2;
@property (weak, nonatomic) IBOutlet UITextField *checkcode_tx;
@property (weak, nonatomic) IBOutlet UIButton *getcode_btn;
@property (weak, nonatomic) IBOutlet UIButton *register_btn;
@property (weak, nonatomic) IBOutlet UIButton *protcolbtn;
@property (weak, nonatomic) IBOutlet UIView *tipview;

@end

@implementation YSRegisterxmViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    

    self.pass_tx1.delegate = self;
    
    self.pass_tx2.delegate = self;
    
    self.checkcode_tx.delegate = self;
    
    self.title = @"项目方注册";
}
- (void)viewDidLayoutSubviews{
    [super viewDidLayoutSubviews];
    
    [[YSDoViewManager sharedmanager] settoyuanWithview:@[self.userview,self.mailview,self.phoneview,self.passview1,self.passview2,self.getcode_btn,self.register_btn,self.checkview]];
    
}
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    [self.view endEditing:YES];
}
- (IBAction)protcolbtnclick:(UIButton *)sender {
    self.protcolbtn.selected = !self.protcolbtn.selected;
}
- (IBAction)closebtnclick:(UIButton *)sender {
    self.tipview.hidden = YES;
    
}

// 跟随键盘
-(void)changeViewFrame:(NSNotification *)noti{
    //1.获取 结束时候的Frame即可
    //    NSLog(@"%@",noti);
    //2.获取结束的Frame
    CGRect endRect =  [noti.userInfo[@"UIKeyboardFrameEndUserInfoKey"]CGRectValue];
    //拿 结束的Frame中的y值 跟界面的高度做减法 得到 最终 控制器的View 的y值
    CGFloat endY = endRect.origin.y-self.view.frame.size.height+100;
    
    //设置给控制器的View的Frame即可
    CGRect oldFrame=self.view.frame;
    if (endY>0) {
        endY = 0;
    }
    oldFrame.origin.y=endY;
    
    
    self.view.frame=oldFrame;
}

- (void)textFieldDidBeginEditing:(UITextField *)textField{
    
    if ([textField isKindOfClass:[YSTextfield class]]) {
        [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(changeViewFrame:) name:UIKeyboardWillChangeFrameNotification object:nil];
        
    }else{
        [[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillChangeFrameNotification object:nil];
    }
    
}

- (void)textFieldDidEndEditing:(UITextField *)textField{
    [[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillChangeFrameNotification object:nil];
}

- (void)dealloc
{
    [[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillChangeFrameNotification object:nil];
    
}



@end
